<template>
  <div>
    <f-table ref="table" size="small" rowKey="processId" :columns="columns" :scroll="{x:true}" :multiple="false"
             :operator="operator" :params="queryParam" :api="api.tasktodo.listDone"
             handler="drugsPlanTaskTodoListHandler">
        <span slot="paymentType" slot-scope="text, record, index">
            <a-tag color="#2db7f5" v-if="record.paymentTypeCode=='PT_01'">采购预付款</a-tag>
            <a-tag color="#f50" v-if="record.paymentTypeCode=='PT_02'">快递费</a-tag>
            <a-tag color="#108ee9" v-if="record.paymentTypeCode=='PT_03'">销售费用</a-tag>
            <a-tag color="#87d068" v-if="record.paymentTypeCode=='PT_04'">其他</a-tag>
            <a-tag color="#d01784" v-if="record.paymentTypeCode=='PT_05'">市场保证金</a-tag>
            <a-tag color="#d08014" v-if="record.paymentTypeCode=='PT_06'">开票税金</a-tag>
        </span>
      <span slot="action" slot-scope="text, record">
          <template>
             <a href="javascript:;" @click="processImg(record)">审批进度</a>
          </template>
        </span>
    </f-table>
    <process-image ref="processImg" v-if="processImageVisible" :visible.sync="processImageVisible"
                   :processInstanceId="processInstanceId"></process-image>
  </div>
</template>
<script>

  import api from './../js/api'
  import ProcessImage from '../../process/process_image'

  export default {
    name: 'TableList',
    components: {
      ProcessImage
    },
    data() {
      let me = this
      //操作按钮
      let operator = []

      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        processInstanceId: '',
        processImageVisible: false,
        // 表头
        columns: [
          {
            title: '#',
            width: '60',
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '操作',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          },
          {
            title: '药品',
            align: 'center',
            dataIndex: 'drugsName'
          },
          {
            title: '采购数量',
            align: 'center',
            dataIndex: 'drugsNum'
          },
          {
            title: '采购价',
            align: 'center',
            dataIndex: 'costPrice'
          },
          {
            title: '采购金额',
            align: 'center',
            dataIndex: 'planAmount'
          },
          {
            title: '差额',
            align: 'center',
            dataIndex: 'returnAmount'
          },
          {
            title: '采购日期',
            align: 'center',
            dataIndex: 'planDate'
          },
          {
            title: '审批状态',
            align: 'center',
            dataIndex: 'checkState'
          },
          {
            title: '创建日期',
            align: 'center',
            dataIndex: 'createTime'
          }
        ],
        operator: operator
      }
    },
    created() {
    },
    methods: {
      onLoad() {
        this.$refs.table.refresh()
      },
      processImg(task) {
        this.processInstanceId = task.processInstanceId
        this.processImageVisible = true
      },
      /**
       * 查询事件
       * @param searchParams
       */
      searchTable(searchParams) {
        this.queryParam = Object.assign(this.queryParam, searchParams)
        this.$refs.table.refresh(true, searchParams)
      }
    }
  }
</script>
